<!-- components/evaluate-components/index.wxml -->
<template>
	<view class="evaluateBox">
		<view class="lists" v-if="commontList.length > 0">
			<block v-for="(item, index_) in commontList" :key="index_">
				<view class="item">
					<view class="item-header">
						<view class="icon"><image :src="userState.headimgurl | formatUrl" mode="widthFix" style="width:100%" @tap="showheadImg(userState.headimgurl)" /></view>
						<view class="name-time">
							<text class="name">{{userState.nickname}}</text>
							<text class="time">{{ item.createTime }}</text>
						</view>
					</view>
					<view class="info">
						<view class="evaluate-content">
							<text style="color: #666;">{{ item.comment || '用户暂未评价' }}</text>
							<view class="imgs" v-if="item.imgsList.length >= 1">
								<block v-for="(imgurl, index) in item.imgsList" :key="index">
									<view class="imgs-box">
										<image :src="imgurl | formatUrl" mode="aspectFill" @click="previewImg(imgurl,item.imgsList)"></image>
									</view>
								</block>
							</view>
							<view class="feedback-star-view" style="margin-left: 0px;display: flex; align-items: center; margin-bottom: 5px;justify-content: flex-end;">
								<view style="font-size: 13px;">商品评价 </view>
							    <text style=" transform: scale(0.7);" class="feedback-star" v-for="(value,key) in stars" :key="key" :class="key < item.goodsGrade ? 'active' : ''"></text>
							</view>
							<view class="evaluate-content_reply" v-show="item.returnDesc">
							  <span class="evaluate-content_reply_text">{{item.returnUserName}}：</span>
							  <span class="evaluate-content_reply_text1">
								  {{item.returnDesc}}
							  </span>
							</view>
						</view>
					</view>
				</view>
			</block>
		</view>
		<empty src="empty" v-else title="暂无评论" />
	</view>
</template>

<script>
//数据模拟

import {  
	mapState,  
} from 'vuex'; 
import empty from '@/components/empty.vue'
export default {
	props: {
		//评价列表数据
		commontList: {
			type: Array,
			default: function () {
				return []
			}
		},
		//是否显示总评价数量
		isShowTotal: {
			type: Boolean,
			default: true
		},
		//是否显示评价前面的图标
		isShowIcon: {
			type: Boolean,
			default: true
		},
		//总评分
		rate: {
			type: Number,
			default: 4.6
		}
	},
	data() {
		return {
			stars: [1,2,3,4,5]
		}
	},
	computed: {
		...mapState(['userState'])
	},
	filters: {
		formatUrl: function(url) {
			return url && url.indexOf('http') !== -1 ? url : 'http://106.13.76.109:8080/xsmall/sys/common/view/'+ url
		}
	},
	components: {
		empty
	},
	methods: {
		showheadImg(url) {
			const src = url.indexOf('http') !== -1 ? url : 'http://106.13.76.109:8080/xsmall/sys/common/view/'+ url;
			uni.previewImage({
				current: src,
				urls: [src]
			});
		},
		previewImg(url,urllist){
			let urls = urllist.map(item => {
				return item.indexOf('http') !== -1 ? item : 'http://106.13.76.109:8080/xsmall/sys/common/view/'+ item
			})
			uni.previewImage({
				current: url.indexOf('http') !== -1 ? url : 'http://106.13.76.109:8080/xsmall/sys/common/view/'+ url,
				urls,
				loop: true,
			});
		}
		
	}
};
</script>
<style scoped>
page {
	background-color: #f8f8f8;
}
@import './iconfont.css';
.evaluateBox {
	width: 100%;
	margin-bottom: 120upx;
}

.evaluate-header {
	width: 100%;
	height: 80upx;
	display: flex;
	justify-content: space-between;
	padding: 20upx;
	align-items: center;
	margin-bottom: 12upx;
	box-sizing: border-box;
	border-bottom: 1upx solid #e5e5e5;
}

.evaluateBox .title {
	display: flex;
	align-items: center;
	color: #000000;
	font-size: 30upx;
}

.total {
	/* flex: 1; */
	height: 100%;
	font-size: 30upx;
	color: #d76d9d;
	display: flex;
	align-items: center;
	justify-content: flex-end;
}

.stars {
	width: 180upx;
	height: 36upx;
	position: relative;
}
.lists .item {
	padding: 20upx;
	display: flex;
	flex-direction: column;
	/* height: auto; */
	/* align-items: center; */
	font-size: 22upx;
	color: #999;
	margin-bottom: 20upx;
	background-color: white;
}
.lists .item .item-header {
	display: flex;
	flex-direction: row;
}

.lists .item .icon {
	width: 60upx;
	height: 60upx;
	border-radius: 50%;
	overflow: hidden;
	margin-right: 10upx;
	/* align-self: flex-start; */
}

.lists .item .info {
	flex: 1;
	font-size: 26upx;
	color: #666;
}

.item-header .name-time {
	display: flex;
	flex-direction: column;
	padding-bottom: 6upx;
	line-height: 32upx;
}
.item-header .name-time .name {
	display: flex;
	flex-direction: column;
	padding-bottom: 6upx;
	color: #000;
}
.item-header .name-time .time {
	font-size: 12px;
}

.lists .info .evaluate-content {
	color: #000;
	font-size: 28upx;
	text-align: left;
	padding: 6upx 0px 0px 74upx;
}
.info .evaluate-content .imgs {
	display: flex;
	flex-wrap: wrap;
	padding-top: 6upx;
}
.evaluate-content .imgs .imgs-box {
	padding-right: 10upx;
	box-sizing: border-box;
}
.evaluate-content .imgs .imgs-box image{
	width: 160upx;
	height: 160upx;
	border: 1px solid #eee;
}
.evaluate-content .evaluate-content_reply {
  margin-top: 24upx;
  background-color: #f8f8f8;
  border-radius: 5px;
  padding: 24upx;
  min-height: 100upx;
  font-size: 26upx;
  position: relative;
}
 .evaluate-content .evaluate-content_reply:before {
        content: '';
        position: absolute;
        left: 1em;
        top: calc(-2em + 2px);
        border: 1em solid transparent;
        border-bottom-color: #f8f8f8;
		border-radius: 50%;
    }
.evaluate-content .evaluate-content_reply_text {
	color: #666;
}
.evaluate-content .evaluate-content_reply_text1 {
  color: #333;
}

/* .evaluate-content .imgs .imgs-box:nth-child(4n+1){
	padding-left: 0;
}
.evaluate-content .imgs .imgs-box:nth-child(4n){
	padding-right: 0;
} */
.no-lists {
	padding: 20upx 0;
	text-align: center;
	font-size: 24upx;
	color: #666;
}
</style>
